package com.example.baseapp.base.validator;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.lang.annotation.Annotation;
import java.util.function.Predicate;

/**
 * BaseValidator class
 *
 * @author zhangl
 * @date 2022/4/30 18:46
 */
public  abstract class BaseValidator <T extends Annotation,R> implements ConstraintValidator<T, R> {
    protected Predicate<R> predicate = c -> true;

    @Override
    public boolean isValid(R baseEntity, ConstraintValidatorContext constraintValidatorContext) {
        return predicate.test(baseEntity);
    }
}
